<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // let obj={
        //     name:"唐玮"
        // }
        // let tw={
        //     [obj]:"帅哥"
        // }
        // console.log(tw["[object Object]"]);
        // console.log(obj.name+tw[obj]);

    //Map
    //；两种存法
    // let map=new Map(["name","唐玮"],["age",20]);//链式存储
    let map=new Map();
    map.set("name","唐玮");//字符串
    map.set(function(){},"函数");//存函数
    map.set({},"对象")//存对象
    map.set(1,"hh1")//数值
    console.log(map);
    

     //遍历map
//   for (const maps of map) {
//       console.log(maps);
//   }
//删除键值,只需删除键就行delete
    map.delete("name");
    console.log(map);
//修改set
    map.set("name","唐家辉");
    console.log(map);
  //查询 get
  console.log(map.get("name"));
  //clear 清空
//   map.clear();
//   console.log(map.size);//0
let obj={
    name:"唐玮"
};
map.set(obj,"名字");
console.log(map);
//查询
console.log(map.get(obj));

//遍历map
 console.log(map.keys());//键的形式
 console.log(map.values());//值的形式
console.log(map.entries());//entries迭代器


// for (const item of map) {
//     console.log(item);
// }
//   for(const [key,value]of map.entries()){
//        console.log(key,value);
//   }

//forEach
map.forEach((value,index)=>{ console.log(index,value);});
    </script>
</body>
</html>